﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SARD.Classes;
using ZedGraph;

namespace SARD.Aux_Forms
{
    public partial class histogram : Form
    {
        /// <summary>
        /// This function creates a graph based in an array and two points, initial and final.
        /// </summary>
        /// <param name="histogramarray">
        /// It's the histogram data itself
        /// </param>
        /// <param name="p">
        /// It's a pair of point where the firts is the initial and the second is the final.
        /// </param>
        public histogram(double[] histogramarray, Point p)
        {
            InitializeComponent();
            GraphPane pane = zedGraphControl1.GraphPane;
            double[] array = new double[p.Y - p.X + 1];

            pane.Title.Text  = "Histograma";
            pane.XAxis.Title.Text = "Pixel Value";
            pane.YAxis.Title.Text = "Contagens";
            
            for (int i = 0; i < p.Y - p.X + 1; i++)
                array[i] = (double)(i+p.X);

            BarItem myCurve = pane.AddBar("Histograma da Região selecionada", array, histogramarray, Color.Red);

            
            myCurve.Bar.Fill = new Fill(Color.Red);
            zedGraphControl1.AxisChange();
        }


        /// <summary>
        /// Closes this form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
